package com.chh.pdapp.record.command;


import com.chh.pdapp.assembler.RecordAssembler;
import com.chh.pdclient.dto.RecordAddCmd;
import com.chh.pdclient.dto.data.RecordVO;
import com.chh.pddomain.gateway.RecordGateway;
import com.chh.pddomain.record.RecordEntity;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@AllArgsConstructor
public class RecordAddCmdExe {

    private final RecordGateway recordGateway;

    public RecordVO execute(RecordAddCmd cmd) {
        RecordEntity entity = recordGateway.save(RecordAssembler.toAddEntity(cmd));

        return RecordAssembler.toRecordVO(entity);
    }
}
